#ifndef FLUORO4030ESINGLE_H
#define FLUORO4030ESINGLE_H

#include <QtGui/QMainWindow>
#include "ui_fluoro4030esingle.h"
#include <windows.h>
#include <QTime>
#include <vector>
#include "HcpErrors.h"
#include "HcpFuncDefs.h"
#include "YK16GrayImage.h"
#define MAX_LINE_LENGTH 1024

class Advantech;
class QTimer;

using namespace std;

struct ADVLOG{
	double fTime;
	double IDI0;
	double IDI1;
	double IDI2;
	double IDI3;
	double IDI4;
};

//class QStandardItemModel;

class Fluoro4030eSingle: public QMainWindow
{
	Q_OBJECT

public:
	Fluoro4030eSingle(QWidget *parent = 0, Qt::WFlags flags = 0);
	~Fluoro4030eSingle();
	void AddGraphData(double sec, int res0, int res1, int res2, int res3, int res4);
	/*void ExamplePlot();
	void ReleaseMemory();	*/
	//DWORD	WINAPI ImgDisplayThread(LPVOID lpParameter);
	//DWORD	WINAPI ImgSaveThread(LPVOID lpParameter);

	public slots:		
		void SLT_SetReceptorMode();
		void SLT_Init();
		void SLT_PrepareBuffer();		
		void SLT_StartGrabber();
		void SLT_StartThreads();
		void SLT_StartRecord();
		void SLT_StopRecord();
		void SLT_StopGrabber();
		void SLT_CloseLink();
		void timerMain_event();
		void SLT_DrawGraph();
		void SLT_BeamRelayCheck();

		void SLT_FrmGoFirst();
		void SLT_FrmGoPrev();
		void SLT_FrmGoNext();
		void SLT_FrmGoLast();
		void SLT_FrmSaveCurrent();
		void SLT_FrmSaveAll();


		void SLT_DrawCurrentImage();
		void SLT_SetReceptorPath();

		void SLT_StartMainTimer();
		void SLT_StopMainTimer();
		void SLT_SaveAdvantechLog();


		/*void SLT_OpenMultipleFiles();
		void SLT_UpdateScanRadio();		
		void SLT_LoadDefaultGraphRange();
		void SLT_ExportCurrentGraph();
		void SLT_UpdateTable();
		void SLT_CopyTableSelectionToClipBoard();
		void SLT_DrawCurrentImage();*/

public:

	YK16GrayImage m_crntYKImage;
	int m_iImgIdx;
	//QStandardItemModel *m_pTableModel;

public:
	SAcqPrms m_acqPrms;
	QString m_strFrameReadyName;

	Advantech *m_Advantech;
	QTimer *m_timerMain;	
	bool m_bBeamRelayIsOpen;

	int m_iWidth;
	int m_iHeight;

	bool m_bSelectedPanel;
	bool m_bPrepRequest;
	bool m_bExposeRequest;
	bool m_bPanelReady_0;
	bool m_bPanelReady_1;
	double m_fElapsedSec;
	QTime m_startTime;

	int m_iReceptorMode;

	vector<ADVLOG> m_vAdvantechIDI;	

	QPoint View2Data(QPoint viewPt, int viewWidth, int viewHeight, int dataWidth, int dataHeight);
	QPoint Data2View(QPoint dataPt, int viewWidth, int viewHeight, int dataWidth, int dataHeight);


private:
	Ui::Fluoro4030eSingleClass ui;
};

#endif // FLUORO4030ESINGLE